<?php
// Module definition
$module['name'] = 'Backups';
$module['description'] = 'Provides the facility to make backups of e-mail, database and web data for each domain';
$module['depends'] = array('unix_users');

switch($action) {
	case 'register':
		// Table structure for table `backups`
		$SQL = "
		CREATE TABLE `backups` (
		  `id` int(11) NOT NULL auto_increment,
		  `type` varchar(8) NOT NULL default '',
		  `name` varchar(200) NOT NULL default '',
		  `contents` varchar(200) NOT NULL default '',
		  `location` varchar(200) NOT NULL default '',
		  `schedule` varchar(200) NOT NULL default '',
		  PRIMARY KEY  (`id`),
		  ) TYPE=MyISAM;";
		if (!mysql_query($SQL))
			return false;
		break;
	case 'unregister':
		$SQL = 'DROP TABLE IF EXISTS backups';
		if (!mysql_query($SQL))
			return false;
		break;
	case 'hook':
		register_hook('web:menu', 'backups_menu');
		register_hook('web:lang', 'backups_lang');
		register_hook('web:cfg:default', 'backups_cfg');
		// Setup panel functions
		register_hook('web:domain:backups', 'backups_domain');
		register_hook('web:reseller:backups', 'backups_reseller');
		// Setup the backup manager (manages backing up and restoring backups)
		register_hook('server:commit:backup:manager', 'backups_manager', 0);
		// Setup backup hooks
		register_hook('server:commit:backup:run', 'backups_backup', 0);
		register_hook('server:commit:backup:store', 'backups_generate_archive', 0);
		register_hook('server:commit:backup:store', 'backups_ftp_archive', 1);
		// Setup restore hooks
		register_hook('server:commit:restore:run', 'backups_restore', 0);
		register_hook('server:commit:restore:store', 'backups_ftp_archive', 0);
		break;
}
?>
